package com.campus.help.common;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 学生状态枚举
 *
 * @author campus-help
 * @since 2025-09-18
 */
@Getter
@AllArgsConstructor
public enum StudentStatus {

    /**
     * 正常
     */
    NORMAL(0, "正常"),

    /**
     * 禁用
     */
    DISABLED(1, "禁用"),

    /**
     * 毕业
     */
    GRADUATED(2, "毕业"),

    /**
     * 休学
     */
    SUSPENDED(3, "休学");

    /**
     * 状态码
     */
    private final Integer code;

    /**
     * 状态描述
     */
    private final String description;

    /**
     * 根据状态码获取枚举
     */
    public static StudentStatus fromCode(Integer code) {
        for (StudentStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown student status code: " + code);
    }
}
